package proxy.jdkproxy;

import proxy.MyInvocationHandler;
import rpc.tcp.client.ProxyHandler;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @program: java-base->Test
 * @description: test
 * @author: G_Y
 * @create: 2019-08-19 18:52
 **/
public class Test {

    public static void main(String[] args) {
        // 被代理对象
        UserService userService = new UserServiceImpl();
        //
        MyInvocation h = new MyInvocation(userService);

        UserService instance = (UserService) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                userService.getClass().getInterfaces(), h);
        System.out.println(instance);

//        System.out.println(instance.getUserNameById(1222));
//        System.out.println(instance == h.proxyObj);

//        UserService serviceProxy = new UsersServiceProxy(h);
//        serviceProxy.getUserNameById(11);
//        System.out.println(serviceProxy);
    }
}
